/*
 * =====================================================================================
 *
 *       Filename:  mem.c
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2010年09月19日 09时47分18秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  YOUR NAME (), 
 *        Company:  
 *
 * =====================================================================================
 */
#include "me/mem.h"
#include <stdlib.h>


except_t Allocation_Failed =  {
	"Allocation_Failed",
	"..."
};

except_t FreeNullPointer_Failed =  {
	"FreeNullPointer_Failed",
	"..."
};

void *
mem_calloc(size_t nmemb, size_t size)
{
	void *p = calloc(nmemb, size);
	if (!p) RAISE(Allocation_Failed);
	return p;
}

void *
mem_malloc(size_t size)
{
	void *p = malloc(size);
	if (!p) RAISE(Allocation_Failed);
	return p;
}

void 
mem_free(void *ptr)
{
	if (!ptr) RAISE(FreeNullPointer_Failed);
	free(ptr);
}

void *
mem_realloc(void *ptr, size_t size)
{
	void *p = realloc(ptr, size);
	if (!p) RAISE(Allocation_Failed);
	return p;
}

